<?php 
require_once(dirname(__FILE__)."/config.php");
CheckPurview('sys_Edit');
require_once(dirname(__FILE__)."/../include/inc_photograph.php");
header("Content-Type: text/html; charset={$cfg_ver_lang}");
if($cfg_photo_support==""){ echo "你的系统没安装GD库，不允许使用本功能！"; }
$ImageWaterConfigFile = dirname(__FILE__)."/../include/inc_photowatermark_config.php";
if(empty($action)) $action = "";
if($action=="save")
{
   $vars = array('photo_markup','photo_markdown','photo_wwidth','photo_wheight','photo_waterpos','photo_watertext','photo_fontsize','photo_fontcolor','photo_diaphaneity');
   $configstr = "";
   foreach($vars as $v){
   	 ${$v} = str_replace("'","",${$v});
   	 $configstr .= "\${$v} = '".${$v}."';\r\n";
   }
   $shortname = "";
   if(is_uploaded_file($newimg)){
   	  $imgfile_type = strtolower(trim($newimg_type));
      if(!in_array($imgfile_type,$cfg_photo_typenames)){
		  ShowMsg("上传的图片格式错误，请使用 {$cfg_photo_support}格式的其中一种！","-1");
		  exit();
	   }
	   if($imgfile_type=='image/bmp') $shortname = ".bmp";
	   else if($imgfile_type=='image/png') $shortname = ".png";
	   else if($imgfile_type=='image/gif') $shortname = ".gif";
	   else $shortname = ".jpg";
	   $photo_markimg = 'mark'.$shortname;
	   @move_uploaded_file($newimg,dirname(__FILE__)."/../include/data/".$photo_markimg);
   }
   $configstr .= "\$photo_markimg = '{$photo_markimg}';\r\n";
   $configstr = "<"."?php\r\n".$configstr."?".">\r\n";
   $fp = fopen($ImageWaterConfigFile,"w") or die("写入文件 $ImageWaterConfigFile 失败，请检查权限！");
   fwrite($fp,$configstr);
   fclose($fp);
   echo "<script>alert('修改配置成功！');</script>\r\n";
}
require_once($ImageWaterConfigFile);


require_once(dirname(__FILE__)."/templets/sys_info_mark.htm");

ClearAllLink();
?>
